package com.singzi.leetcode.jianzhiOffer2;

import java.util.LinkedList;
import java.util.Queue;

public class T0042 {
}
class RecentCounter {
    Queue<Integer> queue;
    public RecentCounter() {
        queue = new LinkedList<>();

    }

    public int ping(int t) {
        while (!queue.isEmpty() && queue.peek() < t - 3000){
            queue.remove();
        }
        queue.add(t);
        return queue.size();
    }
}